<template>
  <div v-if="mood">
    <breadcrumb></breadcrumb>
    <div class="titleBox">
      <!-- icon-dingdan -->
      <div class="iconfontcolor icon-dingdan"></div>
      <div class="infoBox">
        <div class="info_line1">
          <h3 class="tit">建单请求{{ mood.cid }}</h3>
          <div class="tag" v-if="!mood.status">
            <span class="size10"> 待建单</span>
          </div>
          <div class="tag" v-else>
            <span class="size10">已建单</span>
          </div>
        </div>
        <div class="info_line2">
          <div style="margin-right: 15px">发送时间：{{ mood.createTime }}</div>
          <div style="margin-right: 15px">发送人：{{ mood.userName }}</div>
        </div>
      </div>

      <button class="notAdopt_btn" @click="$router.back()">返回</button>
      <button v-if="!mood.status" class="submitBtn" @click="dialogVisible = true">
        创建完成
      </button>
    </div>
    <div class="main">
      <div class="main_item">
        <titleVue :title="'建单信息'"></titleVue>
        <el-descriptions labelClassName="labelDescriptions" contentClassName="contentDescriptions">
          <el-descriptions-item label="发送人">{{
            mood.userName
          }}</el-descriptions-item>
          <el-descriptions-item label="发送时间">{{
            mood.createTime
          }}</el-descriptions-item>
          <el-descriptions-item label="来源">
            <div v-if="mood.platform == 1">司机端</div>
            <div v-else>货主端</div>
          </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="3" border labelClassName="labelBorderDescriptions"
          contentClassName="contentBorderDescriptions">
          <el-descriptions-item label="运营商">{{
            mood.operator
          }}</el-descriptions-item>
          <el-descriptions-item label="车队">{{
            mood.fleetName
          }}</el-descriptions-item>
          <el-descriptions-item label="司机">{{
            mood.driverName
          }}</el-descriptions-item>
          <el-descriptions-item label="运单照片">
            <div class="imageBox">
              <el-image class="imageItem" :src="item.url" v-for="(item, i) in mood.list" :key="i"
                :preview-src-list="[item.url]">
                <template slot="error">
                  <div class="imageError">
                    <i class="el-icon-picture-outline"></i>
                  </div>
                </template>
              </el-image>
            </div>
          </el-descriptions-item>
        </el-descriptions>
      </div>
      <div class="main_item" v-if="mood.status">
        <titleVue :title="'关联信息'"></titleVue>
        <el-descriptions labelClassName="labelDescriptions" contentClassName="contentDescriptions">
          <el-descriptions-item label="关联订单">
            <div class="linkText">{{ mood.orderNo }}</div>
          </el-descriptions-item>
          <el-descriptions-item label="创建人">{{
            mood.createBy
          }}</el-descriptions-item>
          <el-descriptions-item label="创建时间">{{
            mood.creationTime
          }}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>

    <el-dialog class="dialog" title="创建完成" :visible.sync="dialogVisible" width="420px">
      <el-input v-model="orderNumber" placeholder="请输入创建的订单编号" size="small"></el-input>
      <span slot="footer" class="dialog-footer">
        <button class="cancelBtn" @click="dialogVisible = false">取 消</button>
        <button class="submitBtn" @click="finshi">确 定</button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import breadcrumb from "@/components/breadcrumb.vue";
import titleVue from "@/components/titleVue.vue";
import httpApi from "@/http";
import BASEURL from "@/http/BaseUrl";
export default {
  data() {
    return {
      srcList: [],
      dialogVisible: false,
      orderNumber: "",
      orderStatus: 1, //假设 待建单0 已建单1
      mood: null,
    };
  },
  mounted() {
    this.cread();
  },
  methods: {
    async cread() {
      let res = await this.$http.cargoOwnerApi.queryCreateOrderByCid({
        cid: this.$route.query.id,
      });
      this.mood = res.data.data;
    },
    async finshi() {
      let that = this;
      let res = await this.$http.cargoOwnerApi.updateStateByCId({
        orderNo: this.orderNumber,
        cid: this.$route.query.id,
      });
      if (res.data.code == 200) {
        this.$message.success("创建完成");
        setTimeout(() => {
          that.cread();
        }, 1000);
        this.dialogVisible = false;
      }
    },
  },

  components: {
    breadcrumb,
    titleVue,
  },
};
</script>

<style lang="scss" scoped>
.titleBox {
  flex: 1;
  background-color: #fff;
  height: 119px;
  display: flex;
  align-items: center;
  padding: 0 35px;
  margin-bottom: 9px;

  .notAdopt_btn {
    margin-left: auto;
    border-radius: 4px;
    border: 1px solid #d9d9d9;
    height: 36px;
    width: 80px;
    color: #262626;
    font-size: 12px;
    background-color: #fff;
    margin-right: 14px;
    cursor: pointer;
    transition: 0.2s;

    &:hover {
      opacity: 0.8;
      color: #1890ff;
      transition: 0.2s;
      border: 1px solid #1890ff;
    }
  }

  .submitBtn {
    background-color: #1890ff;
    color: #ffffff;
    width: 80px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 12px;
    margin-right: 17px;

    &:hover {
      opacity: 0.8;
    }
  }

  .icon-dingdan {
    font-size: 43px;
    margin-right: 10px;
  }

  .infoBox {
    display: flex;
    flex-direction: column;
    justify-content: center;

    .info_line1 {
      margin-bottom: 3px;
      display: flex;
      align-items: center;

      >.tit {
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        margin-right: 8px;
        color: #262626;
      }

      >.tag {
        background-color: #ecf5fe;
        border-radius: 4px;
        width: 54px;
        height: 20px;
        color: #1890ff;
        display: flex;
        justify-content: center;
        align-items: center;

        .size10 {
          font-size: 12px;
          transform: scale(0.8333);
        }

        &.gery {
          color: #a8b0b6;
          background-color: #a8b0b6;
        }
      }
    }

    .info_line2 {
      display: flex;
      color: #939393;
      font-size: 12px;
    }
  }
}

.main {
  background-color: #fff;
  padding: 35px;
  height: calc(100vh - 255px);

  .main_item {
    margin-bottom: 43px;

    .linkText {
      font-size: 12px;
      line-height: 21px;
      color: #1890ff;
      transition: 0.2s;
      cursor: pointer;

      &:hover {
        opacity: 0.8;
      }
    }
  }
}

.dialog {
  ::v-deep .el-dialog__header {
    border-bottom: 1px solid #f0f0f0;
    padding: 15px 20px;
    color: #262626;
    font-size: 14px;
    font-weight: bold;
    height: 50px;
  }

  .cancelBtn {
    width: 80px;
    height: 36px;
    border: 1px solid #d9d9d9;
    color: #262626;
    font-size: 12px;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    margin-right: 14px;
    transition: 0.2s;

    &:hover {
      border-color: #1890ff;
      color: #1890ff;
    }
  }

  .submitBtn {
    background-color: #1890ff;
    width: 80px;
    height: 36px;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;

    &:hover {
      opacity: 0.8;
    }
  }

  ::v-deep .el-dialog__title {
    font-size: 14px;
    color: #303133;
    font-weight: bold;
  }

  //关闭图标
  ::v-deep .el-dialog__headerbtn .el-dialog__close {
    font-size: 15px;
  }

  ::v-deep .el-dialog__body {
    padding: 20px;
  }
}
</style>
<style lang="scss">
.labelDescriptions {
  color: #939393;
  font-size: 12px;
}

.contentDescriptions {
  color: #262626;
  font-size: 12px;
}

.contentBorderDescriptions {
  color: #666666;
  font-size: 12px;

  >.imageBox {
    display: flex;

    .imageItem {
      width: 109px;
      height: 71px;
      margin-right: 32px;
      cursor: pointer;
    }

    .imageError {
      background-color: #dddddd;
      width: 109px;
      height: 71px;
      display: flex;
      justify-content: center;
      align-items: center;

      >.el-icon-picture-outline {
        font-size: 25px;
      }
    }
  }
}

.labelBorderDescriptions {
  color: #262626 !important;
  font-size: 12px;
  font-weight: bold !important;
  background-color: #f5f5f5 !important;
}
</style>
